package com.gx.smart.construction.ui.house.model;

import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;

import java.util.Objects;

/**
 * @author: xiaosy
 * 时间: 2022/2/11
 * @Description: 房间信息
 * @Version: 1.0
 **/
@Entity(tableName = "room_info")
public class RoomInfo {
    @PrimaryKey
    @androidx.annotation.NonNull
    @ColumnInfo(name = "id", typeAffinity = ColumnInfo.TEXT)
    public String id;
    @ColumnInfo(name = "zone_name", typeAffinity = ColumnInfo.TEXT)
    public String zoneName;//分区名称
    @ColumnInfo(name="building_name", typeAffinity= ColumnInfo.TEXT)
    public String buildingName;//楼栋名称
    @ColumnInfo(name="unit_name", typeAffinity = ColumnInfo.TEXT)
    public String unitName;//单元名称
    @ColumnInfo(name="number", typeAffinity = ColumnInfo.TEXT)
    public String number;//户室号码
    @ColumnInfo(name="sn", typeAffinity = ColumnInfo.TEXT)
    public String sn;//网关编号
    @ColumnInfo(name="page", typeAffinity = ColumnInfo.INTEGER)
    public int page;//网关编号

    @Ignore
    public RoomInfo(@androidx.annotation.NonNull String id, String zoneName, String buildingName, String unitName, String number, String sn) {
        this.id = id;
        this.zoneName = zoneName;
        this.buildingName = buildingName;
        this.unitName = unitName;
        this.number = number;
        this.sn = sn;
    }

    public RoomInfo(@androidx.annotation.NonNull String id, String zoneName, String buildingName, String unitName, String number, String sn,
                    int page) {
       this(id, zoneName, buildingName,unitName, number, sn);
       this.page = page;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        RoomInfo roomInfo = (RoomInfo) o;

        if (!id.equals(roomInfo.id)) return false;
        if (!Objects.equals(zoneName, roomInfo.zoneName))
            return false;
        if (!Objects.equals(buildingName, roomInfo.buildingName))
            return false;
        if (!Objects.equals(unitName, roomInfo.unitName))
            return false;
        if (!Objects.equals(number, roomInfo.number))
            return false;
        return Objects.equals(sn, roomInfo.sn);
    }

    @Override
    public int hashCode() {
        int result = id.hashCode();
        result = 31 * result + (zoneName != null ? zoneName.hashCode() : 0);
        result = 31 * result + (buildingName != null ? buildingName.hashCode() : 0);
        result = 31 * result + (unitName != null ? unitName.hashCode() : 0);
        result = 31 * result + (number != null ? number.hashCode() : 0);
        result = 31 * result + (sn != null ? sn.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "RoomInfo{" +
                "id='" + id + '\'' +
                ", zoneName='" + zoneName + '\'' +
                ", buildingName='" + buildingName + '\'' +
                ", unitName='" + unitName + '\'' +
                ", number='" + number + '\'' +
                ", sn='" + sn + '\'' +
                '}';
    }
}
